import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './assets/css/global.css'
// 导入字体样式
import './assets/fonts/iconfont.css'
import zktable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'

import Nprogress from 'nprogress'
Vue.use(VueQuillEditor)
Vue.component('tree-table',zktable)
import axios from 'axios'
// 配置默认请求地址
axios.defaults.baseURL='http://127.0.0.1:8888/api/private/v1/'
//拦截请求，添加Authorization
axios.interceptors.request.use(config=>{
  Nprogress.start();
  config.headers.Authorization=sessionStorage.getItem('token');
  return config;
})
axios.interceptors.response.use(config=>{
  Nprogress.done();
  return config;
})
Vue.prototype.$axios=axios;

Vue.config.productionTip = false

// 添加全局过滤器
Vue.filter('formatData',(val)=>{
  var time=new Date(val*1000);
  var y=time.getFullYear();
  var M=(time.getMonth()+1+'').padStart(2,0);
  var d=(time.getDate()+'').padStart(2,0);
  var h=(time.getHours()+'').padStart(2,0);
  var m=(time.getMinutes()+'').padStart(2,0);
  var s=(time.getSeconds()+'').padStart(2,0);
  return `${y}-${M}-${d} ${h}:${m}:${s}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
